home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
pctecap.arc
/
ELOCK.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-03-15
|
4KB
|
150 lines
PAGE 55,132
;Program Name: ELOCK.ASM
;Author: William L. Colsher
;Date Written: May 19, 1984
;Purpose: This program provides the 3Com/EtherNet semaphore facility
; to compiled BASIC programs. Three services are provided:
; 1. Lock/Return - sets a semaphore and returns immediately
; 2. Lock/Wait - sets a semaphore, if unsuccessful, retry
; until timeout
; 3. Unlock - unlocks a locked semaphore
;
;Entry Points: LOCK, WAITLOCK, UNLOCK
;
;Calling Parameters: drive_id - integer, specifies EtherShare drive
; containing the data in use. A:=1,
; B:=2, etc.
;
; sem_name - character string, semaphore name
; to be used, must be 31 characters
; or less in length and terminated with
; a null, i.e.: CHR$(0)
;
; time_out - integer, the number of seconds to
; wait while re-trying a lock/wait
;
; error_cd - integer, error code returned by
; EtherShare routine. Actual codes
; are listed with functions.
;
;Calling Sequence: CALL LOCK (drive_id,sem_name,error_cd)
; CALL WAITLOCK (drive_id,sem_name,time_out,error_cd)
; CALL UNLOCK (drive_id,sem_name,error_cd)
;
ASSUME CS:ELOCK
ELOCK SEGMENT 'CODE'
PUBLIC LOCK
PUBLIC UNLOCK
PUBLIC WAITLOCK
LOCK PROC FAR
;Entry point LOCK is used to attempt to LOCK a semaphore.
;
;Error codes returned are: 0 - operation successful
; 1 - semaphor already locked
; 2 - server not responding
; 3 - invalid semaphore name
; 4 - semaphore list full
; 5 - invalid drive_id
; 6 - invalid net address
; 7 - not logged in
; 8 - write to network failed
; 9 - semaphore already locked by caller
PUSH BP ;Save BP
MOV BP,SP ;point to param list
MOV SI,[BP]+10 ;Get drive_id address
MOV AX,[SI] ;retrieve actual drive number
MOV BX,[BP]+8 ;Get pointer to sem_name data
MOV BX,2[BX] ;Skip length and move address into BX
MOV AH,12h ;LOCK function code in AH
MOV SI,0 ;Use drive_id instead of net address
INT 60h ;do it!
MOV SI,[BP]+6 ;get address of error_cd
MOV AH,0 ;clear high byte of AX
MOV [SI],AX ;Give caller the return code
POP BP
RET 6
LOCK ENDP
WAITLOCK PROC FAR
;Entry point WAITLOCK is used to attempt to lock a semaphore. If the
;attempt is not successful, the EtherShare routine will retry
;the operation until it is successful or a timeout occurs.
;
;Error codes returned are: 0 - operation successful
; 1 - time out
; 2 - server not responding
; 3 - invalid semaphore name
; 4 - semaphore list full
; 5 - invalid drive_id
; 6 - invalid net address
; 7 - not logged in
; 8 - write to network failed
; 9 - semaphore already locked by caller
PUSH BP ;save BP
MOV BP,SP ;point to param list
MOV SI,[BP]+12 ;Get drive_id address
MOV AX,[SI] ;retrieve actual drive number
MOV BX,[BP]+10 ;Get pointer to sem_name data
MOV BX,2[BX] ;Skip length and move address into BX
MOV SI,[BP]+8 ;get time_out address
MOV DX,[SI] ;get time_out value
MOV AH,11h ;LOCK/WAIT function code in AH
MOV SI,0 ;Use drive_id instead of net address
INT 60h ;do it!
MOV SI,[BP]+6 ;get address of error_cd
MOV AH,0 ;clear high byte of AX
MOV [SI],AX ;Give caller the return code
POP BP
RET 8
WAITLOCK ENDP
UNLOCK PROC FAR
;Entry point UNLOCK is used to unlock a currently locked semaphore
;
;Error codes returned are: 0 - operation successful
; 1 - semaphore not locked
; 2 - server not responding
; 3 - invalid semaphore name
; 4 - semaphore list full
; 5 - invalid drive_id
; 6 - invalid net address
; 7 - not logged in
; 8 - write to network failed
PUSH BP ;Save BP
MOV BP,SP ;point to param list
MOV SI,[BP]+10 ;Get drive_id address
MOV AX,[SI] ;retrieve actual drive number
MOV BX,[BP]+8 ;Get pointer to sem_name data
MOV BX,2[BX] ;Skip length and move address into BX
MOV AH,13h ;UNLOCK function code in AH
MOV SI,0 ;Use drive_id instead of net address
INT 60h ;do it!
MOV SI,[BP]+6 ;get address of error_cd
MOV AH,0 ;clear high byte of AX
MOV [SI],AX ;Give caller the return code
POP BP
RET 6
UNLOCK ENDP
ELOCK ENDS
END